package com.qf.trade.controller;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 钱包业务接口处理类
 */
@RestController
@RequestMapping("wallet")
@RefreshScope
public class WalletController {

    @Value("${image.baseDir}")
    private String imageBaseDir;

    /**
     * 初始化钱包，并且余额修改为100元
     *
     * @param userId
     * @return success：成功
     */
    @GetMapping("init/{userId}")
    public String init(@PathVariable Long userId) {
        //todo 新增用户钱包
        //todo 修改余额为100元
        System.out.println(String.format("用户【%d】初始化钱包，并且余额修改为100元", userId));
//        throw new RuntimeException("自定义异常");
        return "调用钱包服务，初始化钱包成功";
    }

    @GetMapping("configuration/imageDir")
    public String getConfiguration() {
        return imageBaseDir;
    }

}
